package com.rest.controller;

import com.rest.domain.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

//定义Controller并声明Bean

//增（post）删（delete）改（put）查（get）
@Controller
public class UserController {
    //    设置访问路径
    @RequestMapping(value = "/users", method = RequestMethod.POST)
//    设置返回值类型 return内容即response
    @ResponseBody
    public String save() {
        System.out.println("user saving...");
        return "{'module','user save'}";
    }

    //    设置访问路径
    @RequestMapping(value = "/users/{id}", method = RequestMethod.DELETE)
//    设置返回值类型 return内容即response
    @ResponseBody
    //路径变量
    public String delete(@PathVariable Integer id) {
        System.out.println("user delete" + id);
        return "{'module','delete'}";
    }

    //    设置访问路径
    @RequestMapping(value = "/users", method = RequestMethod.PUT)
//    设置返回值类型 return内容即response
    @ResponseBody
    public String update() {
        System.out.println("user update");
        return "{'module','delete'}";
    }

    //    设置访问路径
    @RequestMapping(value = "/users/{id}", method = RequestMethod.GET)
//    设置返回值类型 return内容即response
    @ResponseBody
    //路径变量
    public String getById(@PathVariable Integer id) {
        System.out.println("user getById" + id);
        return "{'module','getById'}";
    }

    //    设置访问路径
    @RequestMapping(value = "/users", method = RequestMethod.GET)
//    设置返回值类型 return内容即response
    @ResponseBody
    //路径变量
    public String get(Integer id) {
        System.out.println("user get" + id);
        return "{'module','get'}";
    }
}
